'use strict'

module.exports = async function(ctx, next) {
    ctx.set({
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Max-Age': '86400',
        'Access-Control-Allow-Headers': 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With, Token',
        'Access-Control-Allow-Methods': 'PUT, POST, GET, DELETE, OPTIONS'
    })

    if (ctx.method === 'OPTIONS') {
        return ctx.status = 200
    }

    await next()
}